<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class MemberType extends Model
{
    use HasFactory;
    protected $table="member_type";
    protected $guarded=[];

    public function memberTypeAdd($data){
        return self::create($data);
    }

    public function memberTypeDel($id): int
    {
        return self::destroy($id);
    }

    /**
     * 会员类型状态修改
     * @param $id
     * @return mixed
     */
    public function memberTypeBegin($id){
        $data = $this->find($id);
        if ($data['status']=='true'){
            $data->status = 'false';
            return $data->save();
        }
        $data->status = 'true';
        return $data->save();
    }

}
